package com.hh.ListNodeQuestions;

/**
 * @Author hanghao
 * @Date 2023/6/28 14:17
 * @Version 1.0
 * 两两交换链表中的节点
 * middle                            (递归函数系列)
 */


public class No24 {
    public ListNode swapPairs(ListNode head) {
        if(head == null || head.next == null) {
            return head;
        }
        ListNode nextNode = head.next;
        ListNode newNode = swapPairs(nextNode.next);
        nextNode.next = head;
        head.next = newNode;
        return nextNode;
    }
}
